package com.tping.thread;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.Period;
import java.time.ZoneId;
import java.util.Date;
import java.util.Dictionary;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class TestThread {

    private static ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();

    public static void main(String[] args){

        Dictionary dictionary;

        scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
            @Override
            public void run() {
                System.out.println("pppp");
            }
        }, 0, 1, TimeUnit.SECONDS);


        try {

            LocalDate start = getLocalDate("20210712");
            LocalDate end = getLocalDate("20210612");

            System.out.println(end.toEpochDay() - start.toEpochDay());

        } catch (Exception e) {
            e.printStackTrace();
        }


    }

    public static LocalDate getLocalDate(String str){
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
        try {
            Date startDate = format.parse(str);
            Instant instant = startDate.toInstant();
            ZoneId zoneId  = ZoneId.systemDefault();
            return instant.atZone(zoneId).toLocalDate();
        } catch (ParseException e) {
            e.printStackTrace();
        }

        return null;
    }


}
